<template>
<view>

<view class="orderform">
	<view class="ordercenter">
		<view class="ordercontent_box">
			<view class="ordercontent_lable"><view style="display: inline;color: #f77669;margin-right: 10rpx;">01</view>求助标题</view>
			<input type="text" v-model="title" placeholder="请输入"/>
		</view>
		<view class="ordercontent_box">
			<view class="ordercontent_lable"><view style="display: inline;color: #f77669;margin-right: 10rpx;">02</view>姓名</view>
			<input type="text" v-model="name" placeholder="请输入"/>
		</view>
		<view class="ordercontent_box">
			<view class="ordercontent_lable"><view style="display: inline;color: #f77669;margin-right: 10rpx;">03</view>求助联系电话</view>
			<input type="number" v-model="phone" placeholder="请输入"/>
		</view>
		<view class="ordercontent_box">
			<view class="ordercontent_lable"><view style="display: inline;color: #f77669;margin-right: 10rpx;">04</view>服务类型</view>
			<!-- <input type="number" v-model="type" placeholder="请输入"/> -->
			 <picker @change="bindPickerChange"  :value="type" :range="array">
			         <view class="uni-input">{{array[type]}}</view>
			  </picker>
		</view>
		<view class="ordercontent_box">
			<view class="ordercontent_lable"><view style="display: inline;color: #f77669;margin-right: 10rpx;">05</view>所在街镇</view>
			<!-- <input type="number" v-model="streettown" placeholder="请输入"/> -->
			<picker @change="bindPickerChanges"  :value="streettown" :range="array1">
			        <view class="uni-input">{{array[streettown]}}</view>
			 </picker>
		</view>
		<view class="ordercontent_box">
			<view class="ordercontent_lable"><view style="display: inline;color: #f77669;margin-right: 10rpx;">06</view>所在社区</view>
			<!-- <input type="number" v-model="community" placeholder="请输入"/> -->
			<picker @change="bindPickerChangess"  :value="community" :range="array2">
			        <view class="uni-input">{{array[community]}}</view>
			 </picker>
		</view>
		<view class="ordercontent_box">
			<view class="ordercontent_lable"><view style="display: inline;color: #f77669;margin-right: 10rpx;">07</view>服务地址</view>
			<input type="text" v-model="adress" placeholder="请输入"/>
		</view>
		<view class="ordercontent_box">
			<view class="ordercontent_lable"><view style="display: inline;color: #f77669;margin-right: 10rpx;">08</view>期望服务时间</view>
			<!-- <input type="number" v-model="time" placeholder="请输入"/> -->
			
			            <uni-datetime-picker type="date" v-model="time" style="margin-left: 60rpx;height: 60rpx;margin-top: 30rpx;"/>
			    
		</view>
		<view class="ordercontent_box">
			<view class="ordercontent_lable"><view style="display: inline;color: #f77669;margin-right: 10rpx;">09</view>服务说明</view>
			<input type="text" v-model="explain" placeholder="请输入"/>
		</view>
		
	</view>
	<button type="default">确认提交</button>
</view>
</view>
</template>

<script>
          var t = require("../../../utils/request.js"),
		 config = require("../../../utils/config.js").config,
         a = function (t) {
         return t && t.__esModule ? t : { default: t};
         }(require("../../../utils/api.js")),
         e = require("../../../utils/util.js"),
         i = a.default.recruitList,
         o = a.default.dictionaryCounty,
         app = getApp();
	     import {mySList,addService} from '../../../api/activityManage.js'
export default {
  data() {
    return {
	title:'',
	name:'',
	phone:'',
	adress:'',
	explain:'',
	time:'',
	community:'',
	streettown:'',
	type:'',
	array: ['1', '2', '3', '4'],
	array1: ['1', '2', '3', '4'],
	array2: ['1', '2', '3', '4'],
	index:0
    };
  },

   components: {},
  props: {},
  onLoad: function (t) {
    this.getServiceData()
  },
  onReady: function () {},
  onShow: function () {},
  onHide: function () {},
  onUnload: function () {},
  onPullDownRefresh: function () {},
  onReachBottom: function () {},
  onShareAppMessage: function () {
    return {
      title: "让公益更生活 让生活更公益",
      path: "/pages/index/index",
      imageUrl: "/static/images/zyh_logo.jpg"
    };
  },
  watch:{},
  methods: {
	    bindPickerChange: function(e) {
	              this.type = e.target.value
	          },
			  bindPickerChanges: function(e) {
			            this.streettown = e.target.value
			        },
					bindPickerChangess: function(e) {
					          this.community = e.target.value
					      },
	  readdetaile(){
		  
	  },
	  result(val) {
	  				console.log('filter_result:' + JSON.stringify(val));
	  				this.filterResult = JSON.stringify(val, null, 2)
	  			},
	  diandan(){
		  var data = {}
		  data.sid = this.nowId
		  data.vid = app.globalData.zyzId
		  data.remark = this.remark
		  data.need = this.need
		  data.startTime = this.datetimerange[0]
		  data.endTime = this.datetimerange[1]
		  if(!data.vid){
			  uni.navigateTo({
			  	url:"/pages/entry/login"
			  })
		  }
		  if(data.need <=0){
			  uni.showToast({
			  	title:"请输入需求人数",
				icon:"none"
			  })
		  }
		  if(!data.startTime || !data.endTime){
		  			  uni.showToast({
		  			  	title:"请选择时间",
		  				icon:"none"
		  			  })
		  }
		  addService(data).then((ret=>{
			  if(ret.success){
				  uni.showToast({
				  	title:"点单成功",
				  				icon:"none"
				  })
				  
				  
			  }else{
				 uni.showToast({
				 	title:ret.message,
				 				icon:"none"
				 }) 
			  }
			   this.$refs.popup.close()
		  }))
	  },
	   open(id){
				this.nowId = id
	          this.$refs.popup.open('bottom')
	        },
	  addService(id){
		  let uid = app.globalData.zyzId
		  if(!uid){
			  uni.navigateTo({
			  	url:"/pages/entry/login"
			  })
		  }else{
			 uni.navigateTo({
			   url: "/pages/order/order"
			 });
		  }
		  
	  },
	  getServiceData(){
		  // var that = this
		  // var uid = app.globalData.zyzId
		  // if(!uid){
			 //  uni.navigateTo({
			 //  	url:"/pages/entry/login"
			 //  })
		  // }
		  // mySList({"pageSize":this.pageSize,"pageNo":this.page,"id":uid}).then((ret)=>{console.log(ret)
			 //  if (ret.success) {
			 //    ret.data.length < 10 && that.setData({
			 //      noMore: !0
			 //    });
			 //    var i = [];
			 //    ret.data.forEach(function (t) {
			 //  				t.thumb = t.imageUrl ? config.host + "/sysFileInfo/preview?id=" + t.imageUrl : "/static/images/defaultorg.png";
			 //  				i.push(t);
			 //  			}), that.setData({
			 //      actList: i
			 //    });
			 //  }
		  // })
	  },
    getCountyList: function () {
      var a = this,
          e = {
        data: {
          api: o,
          typecode: "areatree",
          parentid: this.countyId || this.cityId || this.provinceId
        }
      };
      return (0, t.request)(e, "common", !1).then(function (t) {
        if (console.log(t), t.data.length > 0 && !a.countyId) {
          var e = [{
            name: "全部",
            id: "",
            _id: "",
            code: ""
          }];
          a.setData({
            countyList: e.concat(t.data)
          });
        } else a.setData({
          countyList: []
        });
      });
    },
    getRecruitList: function () {
			var a = {
				data: {
					api: i,
					pageNo: this.page,
					pageSize: this.pageSize,
					x: app.globalData.longitude,
					y: app.globalData.latitude,
				}
			};
      return (0, t.request)(a, "normal", !0);
    },
  }
};
</script>
<style>
	@import '@/common/uni.css';
	.title {
	    padding: 5px 13px;
	}


.orderform{
	    width: 100%;
	    min-height: 100%;
	    height: auto;
	    background: #fafafa;
	    padding: .4rem .266667rem;
}
.ordercenter{
	    width: 100%;
	    height: auto;
	    background-color: #fff;
	    border-radius: .266667rem;
	    padding: 20rpx 30rpx;
}
.ordercontent_box{
	padding: 30rpx 30rpx;
	padding-bottom: 20rpx;
	font-size: 34rpx;
}
.ordercontent_box input{
	margin-left: 60rpx;
    height: 80rpx;
	border-bottom:1rpx solid #f4f4f4;
	font-size: 28rpx;
}
.orderform button{
	    width: 90%;
	    height: 2.5rem;
	    line-height: 2.5rem;
	    border-radius:30rpx;
	    border: none;
	    background: #f6685a;
	    color: #fff;
	    font-size: 1rem;
		margin-bottom: 50rpx;
}
.orderform .uni-input {
	margin-top: 15rpx;
    height: 30px;
    padding: 7px 12px;
    line-height: 20px;
    font-size: 14px;
    background: #FFF;
    -webkit-box-flex: 1;
    margin-left: 30px;
    -webkit-flex: 1;
    flex: 1;
    border-bottom: 1px solid #f4f4f4;
    padding-bottom: 30px;
}
</style>